@extends('admin.layout.layout')
@section('title','订单列表')
@section('content')
			<div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header">订单列表</h1>
                </div>
                <!-- /.col-lg-12 -->
            </div>
	<div class="row">
	    <div class="col-lg-12">
	        <div class="panel panel-default">
	            <div class="panel-heading">
	                订单列表
	            </div>
	            <!-- /.panel-heading -->
	            <div class="panel-body">
	                <div class="dataTable_wrapper">
	                    <div id="dataTables-example_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer">
	                   	 <form action="{{url('admin/order/index')}}" method="get">
	                   	 	<div class="row">
						         <div class="col-sm-1"></div>
						         <div class="col-sm-1" style="margin-top:5px;">编号</div>
						         <div class="col-sm-2">

							         		<input class="form-control input-sm" placeholder="" aria-controls="dataTables-example" type="text" name="search">

						         </div>
						         
	         					<button type="submit" class="btn btn-info" style="margin-left:25px;">搜索</button>
				         	</div>
				        </form>
				        <div class="row">
				        	<div class="col-sm-12">
				         		<table class="table table-striped table-bordered table-hover dataTable no-footer" id="dataTables-example" role="grid" aria-describedby="dataTables-example_info">
		                        	<thead>
			                            <tr role="row">
				                            <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 100px;" aria-label="Browser: activate to sort column ascending">ID</th>
				                            <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 100px;" aria-label="Browser: activate to sort column ascending">订单编号</th>
				                            <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 184px;" aria-label="Platform(s): activate to sort column ascending">下单时间</th>
				                            <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 150px;" aria-label="Engine version: activate to sort column ascending">收货人</th>
				                            <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 120px;" aria-label="Engine version: activate to sort column ascending">总金额</th>
				                            <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 120px;" aria-label="Engine version: activate to sort column ascending">应付金额</th>
				                            <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 80px;" aria-label="Engine version: activate to sort column ascending">订单状态</th>
				                            <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 120px;" aria-label="CSS grade: activate to sort column ascending">操作</th>
			                            </tr>
		                       		</thead>
	                        	<tbody>
	                        @foreach($orders as $k=>$v)
	                            <tr class="gradeA odd" role="row">
                                    <td class="gid">{{$v->id}}</td>
                                    <td>{{$v->dingdan_id}}</td>
                                    <td>{{date('Y-m-d H:i:s',$v->atime)}}</td>
                                    <td>{{$v->utname}}</td>
                                    <td class="center">{{$v->price}}</td>
                                    <td class="center">{{$v->price}}</td>
                                    <td class="center">{{str_replace([1,2,3],['已支付','未支付','已取消'],$v->status)}}</td>
                                    <td class="center"><a  class="fa fa-trash-o delete" >删除</a> | <a href="{{url('admin/order/update',['id'=>$v->id])}}" class="fa fa-wrench update">修改</a></td>
                                </tr>
                            @endforeach
	                        </tbody>
	                    </table></div></div>
						<div class="col-lg-offset-4">
							{!! $orders->render() !!}
	                    	
						</div>	
	                </div>
	                <!-- /.table-responsive -->
	            </div>
	            <!-- /.panel-body -->
	        </div>
	        <!-- /.panel -->
	    </div>
	    <!-- /.col-lg-12 -->
	</div>
@endsection

@section('myjs')
<script type="text/javascript">
	//绑定删除事件
	$('.delete').click(function(){
		// alert(22);
		//获取当前id
		var id = $(this).parents('.gradeA').find('.gid').html();
		//发送ajax
		var dd = $(this);
		$.get('/admin/order/delete',{id:id},function(data){
			// console.log(data);
			if(data == 1){
				// alert('删除成功');
				dd.parents('.gradeA').hide();
			}else{
				alert('删除失败');
			}
			return false;
		})
	})
</script>
@endsection